<style>
    .control-label span {
        color: red;
    }
</style>

<div class="row">
    <div class="col-lg-12">
        <section class="panel">
            <header class="panel-heading">
                修改密碼
            </header>
            <div class="panel-body">
                <form class="layui-form form-horizontal tasi-form" method="get">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">舊密碼<span>*</span></label>
                        <div class="col-sm-10">
                            <input name="OldPass" type="password" class="form-control" value="" required
                                   lay-verify="required">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">新密碼<span>*</span></label>
                        <div class="col-sm-10">
                            <input name="NewPass" type="password" class="form-control" value="" required
                                   lay-verify="required">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">確認密碼<span>*</span></label>
                        <div class="col-sm-10">
                            <input name="ConfirmPass" type="password" class="form-control" value="" required
                                   lay-verify="required">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"></label>
                        <div class="col-sm-10">
                            <button class="btn btn-primary" lay-submit lay-filter="formSubmit">立即提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </section>
    </div>
</div>

<script>
    layui.use('form', function () {
        var form = layui.form;
        form.on('submit(formSubmit)', function (data) {
            var fields = data.field;
            if (fields.OldPass == fields.NewPass) {
                layer.msg('新舊密碼不能一樣');
                return false;
            }
            if (fields.NewPass != fields.ConfirmPass) {
                layer.msg('兩次密碼輸入不一致！');
                return false;
            }


            global.log('系統設定 - 提交數據', fields);
            global.post('/index.php/user/Setting/mb_SubmitResetPassword', fields, function (msg) {
                if (msg['code'] == ErrCode_Normal) {
                    layer.msg(msg['msg'], {
                        offset: '15px'
                        , icon: 1
                        , time: 1000
                    }, function () {
                        window.location.reload();
                    });
                } else mb_OnMessage(msg);
            });
            return false;
        });
    });
</script>